package com.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.objects.VaultFile;
import com.senditcertified.mail.R;

public class VaultFileAdapter extends BaseAdapter {
	private LayoutInflater li;

	private ArrayList<VaultFile> list;

	public VaultFileAdapter(Context mContext, ArrayList<VaultFile> list) {
		li = LayoutInflater.from(mContext);
		this.list = list;
	}

	@Override
	public int getCount() {
		if (list == null)
			return 0;
		else
			return list.size();
	}

	@Override
	public VaultFile getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		VaultFile item = getItem(position);

		if (convertView == null) {
			view = li.inflate(R.layout.item_vault_file_open_list, null);
			TextView tvFileName = (TextView) view
					.findViewById(R.id.filename_tv);
			tvFileName.setText(item.getName());

		} else {
			view = convertView;
		}

		return view;
	}
}
